package com.esri.android.map;

import android.content.Context;
import android.os.Handler;
import android.view.GestureDetector;
import android.view.MotionEvent;
import android.view.ViewConfiguration;
import java.util.concurrent.atomic.AtomicBoolean;

@Deprecated
/* loaded from: classes.dex */
public class MapGestureDetector {
    private MotionEvent A;
    final OnGestureListener a;
    final GestureDetector b;
    final Handler c;
    private int d;
    private int e;
    private int f;
    private float h;
    private float i;
    private float j;
    private float k;
    private float l;
    private float m;
    private MotionEvent n;
    private final a y;
    private AtomicBoolean z;
    private final int g = 50;
    private boolean o = false;
    private boolean p = false;
    private boolean q = false;
    private boolean r = false;
    private MotionEvent s = null;
    private boolean t = false;
    private boolean u = true;
    private boolean v = false;
    private boolean w = false;
    private boolean x = false;

    @Deprecated
    /* loaded from: classes.dex */
    public interface OnGestureListener {
        boolean onDoubleTap(MotionEvent motionEvent);

        boolean onDoubleTapDrag(MotionEvent motionEvent, MotionEvent motionEvent2);

        boolean onDoubleTapDragUp(MotionEvent motionEvent);

        boolean onDragPointerMove(MotionEvent motionEvent, MotionEvent motionEvent2);

        boolean onDragPointerUp(MotionEvent motionEvent, MotionEvent motionEvent2);

        boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2);

        void onLongPress(MotionEvent motionEvent);

        boolean onLongPressUp(MotionEvent motionEvent);

        void onMultiPointersSingleTap(MotionEvent motionEvent);

        boolean onPinchPointersDown(MotionEvent motionEvent);

        boolean onPinchPointersMove(MotionEvent motionEvent);

        boolean onPinchPointersUp(MotionEvent motionEvent);

        boolean onSingleTap(MotionEvent motionEvent);
    }

    /* loaded from: classes.dex */
    class a implements GestureDetector.OnDoubleTapListener, GestureDetector.OnGestureListener {
        @Override // android.view.GestureDetector.OnDoubleTapListener
        public boolean onDoubleTap(MotionEvent motionEvent) {
            return false;
        }

        @Override // android.view.GestureDetector.OnGestureListener
        public boolean onDown(MotionEvent motionEvent) {
            return false;
        }

        @Override // android.view.GestureDetector.OnGestureListener
        public boolean onScroll(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
            return false;
        }

        @Override // android.view.GestureDetector.OnGestureListener
        public void onShowPress(MotionEvent motionEvent) {
        }

        @Override // android.view.GestureDetector.OnGestureListener
        public boolean onSingleTapUp(MotionEvent motionEvent) {
            return false;
        }

        a() {
        }

        @Override // android.view.GestureDetector.OnGestureListener
        public void onLongPress(MotionEvent motionEvent) {
            if (MapGestureDetector.this.o || !MapGestureDetector.this.q) {
                return;
            }
            MapGestureDetector.this.a(motionEvent);
            MapGestureDetector.this.r = true;
            MapGestureDetector.this.a.onLongPress(motionEvent);
        }

        @Override // android.view.GestureDetector.OnDoubleTapListener
        public boolean onDoubleTapEvent(MotionEvent motionEvent) {
            int action = motionEvent.getAction();
            if (action == 0) {
                MapGestureDetector.this.s = motionEvent;
                MapGestureDetector.this.t = true;
                if (MapGestureDetector.this.b.isLongpressEnabled()) {
                    MapGestureDetector.this.w = true;
                    MapGestureDetector.this.b.setIsLongpressEnabled(false);
                }
            } else if (action != 1) {
                if (action == 2 && motionEvent.getEventTime() - MapGestureDetector.this.s.getEventTime() > 50) {
                    MapGestureDetector.this.v = true;
                    MapGestureDetector.this.a.onDoubleTapDrag(MapGestureDetector.this.s, motionEvent);
                }
            } else {
                if (MapGestureDetector.this.w) {
                    MapGestureDetector.this.b.setIsLongpressEnabled(true);
                    MapGestureDetector.this.w = false;
                }
                MapGestureDetector.this.s = null;
                MapGestureDetector.this.t = false;
                if (MapGestureDetector.this.v) {
                    MapGestureDetector.this.v = false;
                    return MapGestureDetector.this.a.onDoubleTapDragUp(motionEvent);
                }
                return MapGestureDetector.this.a.onDoubleTap(motionEvent);
            }
            return false;
        }

        @Override // android.view.GestureDetector.OnDoubleTapListener
        public boolean onSingleTapConfirmed(MotionEvent motionEvent) {
            if (MapGestureDetector.this.x) {
                MapGestureDetector.this.x = false;
                return MapGestureDetector.this.a.onSingleTap(motionEvent);
            }
            return false;
        }

        @Override // android.view.GestureDetector.OnGestureListener
        public boolean onFling(MotionEvent motionEvent, MotionEvent motionEvent2, float f, float f2) {
            if (MapGestureDetector.this.u) {
                return MapGestureDetector.this.a.onFling(motionEvent, motionEvent2, f, f2);
            }
            return false;
        }
    }

    public MapGestureDetector(Context context, OnGestureListener onGestureListener) {
        a aVar = new a();
        this.y = aVar;
        Handler handler = new Handler();
        this.c = handler;
        this.z = new AtomicBoolean(false);
        this.A = null;
        this.b = new GestureDetector(context, aVar, handler);
        this.a = onGestureListener;
        a(context);
    }

    private void a(Context context) {
        float f = context.getResources().getDisplayMetrics().density;
        this.d = ViewConfiguration.getTapTimeout();
        this.e = ViewConfiguration.getDoubleTapTimeout();
        this.f = (int) ((f * 100.0f) + 0.5f);
    }

    /* JADX WARN: Code restructure failed: missing block: B:19:0x0037, code lost:
        if (r0 != 262) goto L14;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    public boolean onTouchEvent(android.view.MotionEvent r6) {
        /*
            r5 = this;
            android.view.MotionEvent r6 = android.view.MotionEvent.obtain(r6)
            int r0 = r6.getAction()
            int r1 = r6.getPointerCount()
            r2 = 0
            r3 = 1
            if (r1 <= r3) goto L1c
            r5.a(r6)
            r5.o = r3
            r5.x = r2
            boolean r6 = r5.a(r0, r6)
            goto L28
        L1c:
            if (r1 != r3) goto L27
            boolean r4 = r5.o
            if (r4 != 0) goto L27
            boolean r6 = r5.b(r0, r6)
            goto L28
        L27:
            r6 = 0
        L28:
            if (r0 == 0) goto L40
            if (r0 == r3) goto L3a
            r3 = 2
            if (r0 == r3) goto L40
            r3 = 3
            if (r0 == r3) goto L3a
            r3 = 6
            if (r0 == r3) goto L3a
            r3 = 262(0x106, float:3.67E-43)
            if (r0 == r3) goto L3a
            goto L43
        L3a:
            r5.q = r2
            r5.a(r1)
            goto L43
        L40:
            r5.a(r1)
        L43:
            return r6
        */
        throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.MapGestureDetector.onTouchEvent(android.view.MotionEvent):boolean");
    }

    /* JADX INFO: Access modifiers changed from: private */
    public void a(MotionEvent motionEvent) {
        if (this.p) {
            this.a.onDragPointerUp(this.n, motionEvent);
            this.p = false;
        }
    }

    private void a(int i) {
        if (i == 1) {
            this.o = false;
        }
    }

    /* JADX WARN: Code restructure failed: missing block: B:33:0x007e, code lost:
        if (((r2 * r2) + (r4 * r4)) <= r1) goto L40;
     */
    /*
        Code decompiled incorrectly, please refer to instructions dump.
        To view partially-correct code enable 'Show inconsistent code' option in preferences
    */
    private boolean a(int r12, android.view.MotionEvent r13) {
        /*
            Method dump skipped, instructions count: 325
            To view this dump change 'Code comments level' option to 'DEBUG'
        */
        throw new UnsupportedOperationException("Method not decompiled: com.esri.android.map.MapGestureDetector.a(int, android.view.MotionEvent):boolean");
    }

    private boolean b(int i, MotionEvent motionEvent) {
        boolean z;
        boolean z2 = false;
        if (i == 0) {
            this.q = true;
            this.x = true;
            this.p = false;
            this.n = motionEvent;
            z2 = true;
        } else if (i == 1) {
            this.u = true;
            long eventTime = motionEvent.getEventTime() - motionEvent.getDownTime();
            if (!this.p || this.t) {
                z = false;
            } else {
                z = this.a.onDragPointerUp(this.n, motionEvent) | false;
                this.p = false;
                this.n = null;
                if (eventTime > this.e) {
                    this.u = false;
                }
            }
            if (this.r) {
                this.r = false;
                z2 = this.a.onLongPressUp(motionEvent) | z;
            } else {
                z2 = z;
            }
        } else if (i == 2) {
            if (!this.t) {
                z2 = false | this.a.onDragPointerMove(this.n, motionEvent);
                this.p = true;
            }
            this.n = motionEvent;
        }
        return this.b.onTouchEvent(motionEvent) | z2;
    }
}
